﻿<UserControl x:Class="FIFP.DashBoard.Views.UCAppointment_New"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
    xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
    xmlns:converter="clr-namespace:FIFP.DashBoard.Converters"
    xmlns:vm="clr-namespace:FIFP.DashBoard.ViewModel"
    DataContext="{Binding AppointmentVM,Source={StaticResource ServiceLocator}}"
    xmlns:Presentation="clr-namespace:FIFP.Common.Behaviors.CommonEventArgs;assembly=FIFP.Common"
    mc:Ignorable="d">


    <UserControl.Resources>
        <!--<converter:ViewDefinitionToBooleanConverter x:Key="ViewDefinitionToBooleanConverter" />-->
        <DataTemplate x:Key="AppointmentToolTipTemplate">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"></RowDefinition>
                    <RowDefinition Height="Auto"></RowDefinition>
                    <RowDefinition Height="Auto"></RowDefinition>
                    <RowDefinition Height="Auto"></RowDefinition>
                    <RowDefinition Height="Auto"></RowDefinition>
                    <RowDefinition Height="Auto"></RowDefinition>
                    <RowDefinition Height="Auto"></RowDefinition>
                    <RowDefinition Height="Auto"></RowDefinition>
                    <RowDefinition Height="Auto"></RowDefinition>
                    <RowDefinition Height="Auto"></RowDefinition>
                    <RowDefinition Height="*"></RowDefinition>
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto"></ColumnDefinition>
                    <ColumnDefinition Width="*"></ColumnDefinition>
                </Grid.ColumnDefinitions>
                <TextBlock Text="Division: "/>
                <TextBlock Text="{Binding Path=Appointment.Division}" Grid.Column="1"/>
                <TextBlock Grid.Row="1" Text="UnitName: "/>
                <TextBlock Grid.Row="1" Text="{Binding Path=Appointment.UnitName}" Grid.Column="1"/>
                <TextBlock Grid.Row="2" Text="UnitType: "/>
                <TextBlock Grid.Row="2" Text="{Binding Path=Appointment.UnitType}" Grid.Column="1"/>
                <TextBlock Grid.Row="3" Text="UnitStatus: "/>
                <TextBlock Grid.Row="3" Text="{Binding Path=Appointment.UnitStatus}" Grid.Column="1"/>
                <TextBlock Grid.Row="4" Text="Closed Strings: "/>
                <TextBlock Grid.Row="4" Text="{Binding Path=Appointment.SelectedString}" Grid.Column="1"/>
                <TextBlock Grid.Row="5" Text="FluidType: "/>
                <TextBlock Grid.Row="5" Text="{Binding Path=Appointment.FluidType}" Grid.Column="1"/>
                <TextBlock Grid.Row="6" Text="Modified Start: "/>
                <TextBlock Grid.Row="6" Text="{Binding Appointment.Start,StringFormat=dd/MM/yyyy}" Grid.Column="1"/>
                <TextBlock Grid.Row="7" Text="Modified End: "/>
                <TextBlock Grid.Row="7" Text="{Binding Appointment.End,StringFormat=dd/MM/yyyy}" Grid.Column="1"/>
                <TextBlock Grid.Row="8" Text="Modified Duration: "/>
                <TextBlock Grid.Row="8" Text="{Binding Path=Appointment.ModifiedTotalDays}" Grid.Column="1"/>
                <TextBlock Grid.Row="9" Text="Original Duration: "/>
                <TextBlock Grid.Row="9" Text="{Binding Path=Appointment.OriginalTotalDays}" Grid.Column="1"/>
                <!--<TextBlock Grid.Row="8" Text="Overlap: "/>
                <TextBlock Grid.Row="8" Text="{Binding Path=Appointment.IsOverlapped}" Grid.Column="1"/>-->
            </Grid>
        </DataTemplate>

        <SolidColorBrush x:Key="GroupHeaderForeground" Color="#B2020202" />

        <Style x:Key="HorizontalBottomLevelGroupHeaderStyle" TargetType="telerik:GroupHeader" BasedOn="{StaticResource GroupHeaderBaseStyle}">
            <Setter Property="Margin" Value="0 0 -1 0" />
            <Setter Property="Padding" Value="0 0 5 0" />
            <Setter Property="Canvas.ZIndex" Value="-2" />
            <Setter Property="Foreground" Value="Red"/>
            <Setter Property="FontStyle" Value="Italic"/>
        </Style>

    </UserControl.Resources>
    <Grid x:Name="LayoutRoot" Visibility="{Binding ScheduleViewVisibility}">
        <!--<ScrollViewer Grid.Column="0" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto" VerticalAlignment="Top" Style="{StaticResource ScrollViewerStyle1}" Margin="0">-->
            <Grid VerticalAlignment="Top" HorizontalAlignment="Left" Margin="0">
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"></RowDefinition>
                    <RowDefinition Height="*"></RowDefinition>
                </Grid.RowDefinitions>

                <StackPanel Orientation="Horizontal" Grid.Row="0" HorizontalAlignment="Left" Margin="0,0,0,10">
                    <TextBlock Text="Zoom: " Style="{StaticResource SmallHeading}" VerticalAlignment="Center" Margin="0,0,10,0" />
                    <telerik:RadSlider x:Name="radSlider" Width="150" Minimum="{Binding MinTimeRulerExtentValue,Mode=TwoWay}" Maximum="7000" Margin="0" Style="{StaticResource RadSliderStyle1}"
						VerticalAlignment="Center" Value="{Binding ActiveViewDefinition.MinTimeRulerExtent, ElementName=radView, Mode=TwoWay}" LargeChange="50">
                        <i:Interaction.Triggers>
                            <i:EventTrigger EventName="Loaded">
                                <i:InvokeCommandAction Command="{Binding RadSliderLoadCommand}" 
        							CommandParameter="{Binding ElementName=radSlider}" />
                            </i:EventTrigger>
                        </i:Interaction.Triggers>
                    </telerik:RadSlider>

                </StackPanel>

                <Grid Grid.Row="1" VerticalAlignment="Top" HorizontalAlignment="Left">
                    <telerik:RadScheduleView ToolTipTemplate="{StaticResource AppointmentToolTipTemplate}" x:Name="radView" ActiveViewDefinitionIndex="3" MinAppointmentHeight="30" 
                                 AppointmentsSource="{Binding FilteredAppointments}" GroupHeaderStyleSelector="{StaticResource GroupHeaderStyleSelector}" ResourceTypesSource="{Binding ResourceTypes}" 
                                 EditAppointmentDialogStyle="{StaticResource EditAppointmentDialogStyle}" DragDropBehavior="{Binding RadScheduleViewDragDropBehavior}" 
                                 NavigationHeaderVisibility="{Binding NavigationVisibility}" CurrentDate="{Binding CurrentDate}" Background="#FF353c48" BorderBrush="#FF353c48" VerticalAlignment="Top">


                        <i:Interaction.Triggers>


                            <i:EventTrigger EventName="AppointmentCreating">
                                <Presentation:InvokeDelegateCommandAction
                                Command="{Binding Source={StaticResource ServiceLocator},Path=AppointmentVM.AppointmentCreateCommand}"
                                CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=InvokeParameter}" />

                            </i:EventTrigger>

                            <i:EventTrigger EventName="ShowDialog">
                                <Presentation:InvokeDelegateCommandAction
                                Command="{Binding Source={StaticResource ServiceLocator},Path=AppointmentVM.DialogCommand}"
                                CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=InvokeParameter}" />

                            </i:EventTrigger>

                            <i:EventTrigger EventName="Loaded">
                                <i:InvokeCommandAction Command="{Binding GroupTypeResourceLoadCommand}" 
        							CommandParameter="{Binding ElementName=radView}" />
                            </i:EventTrigger>

                            <!--<i:EventTrigger EventName="AppointmentSelectionChanged">
                    <i:InvokeCommandAction Command="{Binding AppointmentSelectionChangedCommand}" 
        							CommandParameter="{Binding ElementName=radView}" />
                </i:EventTrigger>-->

                            <i:EventTrigger EventName="AppointmentEditing">
                                <Presentation:InvokeDelegateCommandAction
                                Command="{Binding Source={StaticResource ServiceLocator},Path=AppointmentVM.AppointmentEditingCommand}"
                                CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=InvokeParameter}" />
                            </i:EventTrigger>

                            <i:EventTrigger EventName="AppointmentEdited">
                                <Presentation:InvokeDelegateCommandAction
            			Command="{Binding AppointmentVM.AppointmentEditCommand, Source={StaticResource ServiceLocator}}"
            			CommandParameter="{Binding InvokeParameter, RelativeSource={RelativeSource Self}}" />
                            </i:EventTrigger>

                            <i:EventTrigger EventName="AppointmentDeleting">
                                <Presentation:InvokeDelegateCommandAction
            			Command="{Binding AppointmentVM.AppointmentDeletingCommand, Source={StaticResource ServiceLocator}}"
            			CommandParameter="{Binding InvokeParameter, RelativeSource={RelativeSource Self}}" />
                            </i:EventTrigger>

                            <i:EventTrigger EventName="AppointmentDeleted">
                                <Presentation:InvokeDelegateCommandAction
            			Command="{Binding AppointmentVM.AppointmentDeleteCommand, Source={StaticResource ServiceLocator}}"
            			CommandParameter="{Binding InvokeParameter, RelativeSource={RelativeSource Self}}" />
                            </i:EventTrigger>



                        </i:Interaction.Triggers>

                        <telerik:RadScheduleView.ViewDefinitions>
                            <telerik:TimelineViewDefinition MinorTickLength="{Binding MinorTickLength}"
                         MajorTickLength="{Binding MajorTickLength}" GroupTickLength="{Binding GroupTickLength}" MaxTimeRulerExtent="Infinity" MinTimeRulerExtent="{Binding MinTimeRulerExtentValue}" TimerulerGroupStringFormat="{}{0:MMM,yyyy}" 
						 VisibleDays="{Binding VisibleDays}"  StretchAppointments="False" StretchGroupHeaders="False">
                            </telerik:TimelineViewDefinition>
                        </telerik:RadScheduleView.ViewDefinitions>

                        <telerik:RadScheduleView.GroupHeaderContentTemplate>
                            <DataTemplate>
                                <TextBlock Name="txtGroup" Foreground="White" Text="{Binding FormattedName}" Margin="0,0,10,0" Width="150" VerticalAlignment="Center" HorizontalAlignment="Right" TextAlignment="Right" FontFamily="Calibri" FontSize="18">

                                </TextBlock>
                            </DataTemplate>
                        </telerik:RadScheduleView.GroupHeaderContentTemplate>


                        <telerik:RadScheduleView.TimeRulerItemStyleSelector>
                            <converter:GroupItemStyleSelector>
                                <converter:GroupItemStyleSelector.DefaultStyle>
                                    <Style TargetType="Control">
                                        <Setter Property="Width" Value="1" />
                                        <Setter Property="Height" Value="0" />
                                    </Style>
                                </converter:GroupItemStyleSelector.DefaultStyle>
                            </converter:GroupItemStyleSelector>
                        </telerik:RadScheduleView.TimeRulerItemStyleSelector>

                    </telerik:RadScheduleView>
                </Grid>

            </Grid>
        <!--</ScrollViewer>-->
    </Grid>
</UserControl>
